package Package.PropertiesCollection.Properties_IO;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class Properties_IO {
    public static final void Properties_IO() throws IOException {
//        void load(InputStream inStream) 从输入字节流读取属性列表（键和元素对）
        
//void load(Reader reader) 从输入字符流读取属性列表（键和元素对）
//void store(OutputStream out, String comments)将此属性列表（键和元素对）写入此 Properties表中，以适合于使用load(InputStream)方法的格式写入输出字节流
//void store(Writer writer,String comments)将此属性列表（键和元素对）写入此 Properties表中，以适合使用load(Reader)方法的格式写入输出字符流
    
    mystore();
    myload();
    }

    private static void myload() throws IOException {
        Properties props=new Properties();
        FileReader fr=new FileReader("D:\\insert\\a.txt");
        props.load(fr);
        fr.close();
        System.out.println(props);
    }

    private static void mystore() throws IOException {
        Properties props=new Properties();
        props.setProperty("itheima001","林青霞");
        props.setProperty("itheima002","张曼玉");
        props.setProperty("itheima003","王祖贤");
        FileWriter fr=new FileWriter("D:\\insert\\a.txt");
        props.store(fr,"ChangCun");
//        store第二个参数为描述信息，为null或者其他
        fr.close();
        System.out.println(props);
    }
}
